import redis
import time


r = redis.StrictRedis(host='localhost', port=6379, db=0)
key = 'test'
# 重置计数器为0
r.getset(key, 0)

for i in (range(3)):
    # r.incr(key, 1)
    # t = r.get(key)
    r.set(r.incr(key, 1), time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))

# 清空redis
# r.flushall()